package com.arpa.ntocc.common.domain.entity;

import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.format.annotation.DateTimeFormat;

import java.time.LocalDateTime;


/**
 * 实体基础类
 *
 * @param <T>
 * @author leo
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class BasicEntity<T extends Model> extends Model<BasicEntity<T>> {


    /**
     * 主键
     */
    @ApiModelProperty(hidden = true)
    @JsonIgnore
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;


    @ApiModelProperty(hidden = true)
    @TableLogic
    @TableField(value = "is_deleted")
    private Integer deleted;


    /**
     * 创建人名称
     */
    @ApiModelProperty(hidden = true)
    @TableField(value = "created_name")
    private String createdName;
    /**
     * 修改人名称
     */
    @ApiModelProperty(hidden = true)
    @TableField(value = "modified_name")
    private String modifiedName;

    /**
     * 创建人
     */
    @ApiModelProperty(hidden = true)
    @TableField(value = "created_by")
    private String createdBy;
    /**
     * 修改人
     */
    @ApiModelProperty(hidden = true)
    @TableField(value = "modified_by")
    private String modifiedBy;
    /**
     * 创建时间
     * 自动填充
     */
    @ApiModelProperty(hidden = true)
    @TableField(value = "gmt_created", fill = FieldFill.INSERT)
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime gmtCreated;

    /**
     * 修改时间
     * 自动填充
     */
    @ApiModelProperty(hidden = true)
    @TableField(value = "gmt_modified", fill = FieldFill.INSERT_UPDATE)
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime gmtModified;


    @ApiModelProperty(hidden = true)
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @TableField(exist = false)
    private LocalDateTime gmtCreatedStart;

    @ApiModelProperty(hidden = true)
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @TableField(exist = false)
    private LocalDateTime gmtCreatedEnd;

    @ApiModelProperty(hidden = true)
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @TableField(exist = false)
    private LocalDateTime gmtModifiedStart;

    @ApiModelProperty(hidden = true)
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @TableField(exist = false)
    private LocalDateTime gmtModifiedEnd;

}

